package com.swipemaster.opengl;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.view.MotionEvent;

import com.swipemaster.common.Coords;
import com.swipemaster.levels.Level;

public class OpenGLView extends GLSurfaceView
{
    private GameRenderer gameRenderer;
    private Level level;
    
    public OpenGLView(Context context, Level level)
    {
        super(context);
        this.level = level;
        gameRenderer = new GameRenderer(this, level);
        setRenderer(gameRenderer);
        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e)
    {
    	int x = (int) e.getX();
    	int y = (int) e.getY();
    	level.setPlayerPosition(Coords.getUniversal(x, y));
    	requestRender();
        return true;
    }
}